﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RZUIBaseView : MonoBehaviour
{
    protected int m_uiID;// 事件ID

    protected RZUIBaseCtrl m_ctrl;

    private int m_Order;

    public void Init (RZUIBaseCtrl ctrl, RZUIVo vo)
    {
        m_ctrl = ctrl;
        m_uiID = vo.UIID;
        m_Order = vo.Order;
    }

    public virtual void Show()
    {
        if(transform.parent == null)
        {
            // 调用显示 UI 事件 UIADDCanvs
        }
        else
        {
            gameObject.SetActive (true);
        }
    }

    public virtual void CloseView()
    {
        // UIHide事件
    }
    public virtual void Hide () { gameObject.SetActive (false); }

    public void CtrlDestroy() { m_ctrl = null; }

    public int Order { get { return m_Order; } }

    private void OnDestroy ()
    {
        if(m_ctrl != null && m_ctrl.CompareView(this))
        {
            m_ctrl.DestroyUI ();
        }
        m_ctrl = null;
    }
}
